package hapi.log;

#if php
import php.io.File;
import php.io.FileOutput;
#elseif neko
import neko.io.File;
import neko.io.FileOutput;
#end

class FileLogger extends BasicLogger {
	
	var out:FileOutput;
	
	public function new(path) {
		super();
		try {
			out = File.append(path, false);
		}catch (e:Dynamic) {
			throw "Could not create file output at path for " + path;
		}
	}
	
	public override function log(msg:Dynamic) {
		out.writeString(msg+"\n");
		out.flush();
	}
}